package com.datasource.dynamicdatasource.controller;


import com.baomidou.dynamic.datasource.annotation.DS;
import com.datasource.dynamicdatasource.model.Student;
import com.datasource.dynamicdatasource.model.Teacher;
import com.datasource.dynamicdatasource.service.StudentService;
import com.datasource.dynamicdatasource.service.TeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author sl
 */
@RestController
public class TestDataSourceController {

    @Autowired
    private StudentService studentService;

    @Autowired
    private TeacherService teacherService;

    @GetMapping("/stu")
    public String getStu(){
        List<Student> allStudent = studentService.findAllStudent();
        return allStudent.toString();
    }

    @GetMapping("/tech")
    @DS("teacher")
    public String getTech(){
        List<Teacher> allTeacher = teacherService.findAllTeacher();
        return allTeacher.toString();
    }
}
